package cn.iocoder.yudao.module.iot.dal.mysql.phonemsglog;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.iot.dal.dataobject.deviceeventslog.DeviceEventsLogDO;
import cn.iocoder.yudao.module.iot.dal.dataobject.phonemsglog.PhoneMsgLogDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.iot.controller.admin.phonemsglog.vo.*;

/**
 * 短信和电话消息提醒记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface PhoneMsgLogMapper extends BaseMapperX<PhoneMsgLogDO> {

    default PageResult<PhoneMsgLogDO> selectPage(PhoneMsgLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PhoneMsgLogDO>()
                .eqIfPresent(PhoneMsgLogDO::getPhoneUser, reqVO.getPhoneUser())
                .eqIfPresent(PhoneMsgLogDO::getPhone, reqVO.getPhone())
                .eqIfPresent(PhoneMsgLogDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(PhoneMsgLogDO::getSendType, reqVO.getSendType())
                .betweenIfPresent(PhoneMsgLogDO::getSendTime, reqVO.getSendTime())
                .eqIfPresent(PhoneMsgLogDO::getContent, reqVO.getContent())
                .eqIfPresent(PhoneMsgLogDO::getContentValue, reqVO.getContentValue())
                .eqIfPresent(PhoneMsgLogDO::getTempCode, reqVO.getTempCode())
                .eqIfPresent(PhoneMsgLogDO::getReturnCode, reqVO.getReturnCode())
                .eqIfPresent(PhoneMsgLogDO::getReturnMsg, reqVO.getReturnMsg())
                .betweenIfPresent(PhoneMsgLogDO::getCreateTime, reqVO.getCreateTime())
                .geIfPresent(PhoneMsgLogDO::getCreateTime, reqVO.getTimeStart())
                .leIfPresent(PhoneMsgLogDO::getCreateTime, reqVO.getTimeEnd())
                .orderByDesc(PhoneMsgLogDO::getId));
    }


    default List<PhoneMsgLogDO> getSendList(String deviceName){
        return selectList(PhoneMsgLogDO::getDeviceName, deviceName);
    }

}